#include<iostream>
#include<string>
#include<vector>

using namespace std;
string intToRoman(int num) {
    vector<pair<int, string>> roman = {
        {1000, "M"},
        {900, "CM"},
        {500, "D"},
        {400, "CD"},
        {100, "C"},
        {90, "XC"},
        {50, "L"},
        {40, "XL"},
        {10, "X"},
        {9, "IX"},
        {5, "V"},
        {4, "IV"},
        {1, "I"}
    };
    int idx = 0;
    string res = "";
    while(num > 0 && idx < roman.size()) {
        if (num >= roman[idx].first) {
            num -= roman[idx].first;
            res += roman[idx].second;
        } else if(num < roman[idx].first) {
            idx++;
        }
    }
    return res;
}

int main() {
    int num = 1994;
    string res = intToRoman(1994);
    cout << res << endl;
}
